package com.procurement.general.util;

import com.ruoyi.common.security.annotation.InnerAuth;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Random;

@RestController
@RequestMapping
public class BmUtil {
    @GetMapping("/get/{bt}")
    @InnerAuth
    public String scbm(@PathVariable("bt") String bt){
        // 随机生成两位字母
        Random random = new Random();
        char letter1 = (char) (random.nextInt(26) + 'a');
        char letter2 = (char) (random.nextInt(26) + 'a');

        // 生成当前日期并格式化为 "yyyyMMdd" 格式
        LocalDate currentDate = LocalDate.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
        String formattedDate = currentDate.format(formatter);

        // 随机生成 0~99999 之间的数字，然后补齐 5 位
        int randomNumber = random.nextInt(100000);
        String formattedNumber = String.format("%05d", randomNumber);

        // 拼接字符串
        String finalString =bt + formattedDate + formattedNumber;

        // 输出结果
        System.out.println("生成的随机字符串为：" + finalString);
        return  finalString;
    }
}
